﻿using System;
using System.Net;
using SomeKit.Http;

namespace SomeKit.TypeSafe
{
    public static partial class ClientHelper
    {
        /// <summary>
        /// Executes a "DELETE" method on the resource denoted by <paramref name="uri"/>. Before the request is sent the delegate <paramref name="headerHandler"/> is invoked. 
        /// This is provided for the user, to be able to perform custom manipulation of the header, for ie. custom content- or accept-types or providing special security headers. 
        /// Upon completion only one of the delegates <paramref name="resultHandler"/> (in case of success) or <paramref name="errorHandler"/> (in case of failure) is invoked.
        /// </summary>
        /// <param name="uri">The address of the resource, which is being deleted.</param>
        /// <param name="handler">The delegate to be invoked in case of success.</param>
        /// <param name="errorHandler">The delegate to be invoked in case of failure.</param>
        /// <param name="headerHandler">The delegate provided for custom header customization.</param>
        public static void Delete(this Uri uri, Action handler = null, Action<Exception> errorHandler = null, Action<HttpWebRequest> headerHandler = null)
        {
            uri.Delete(EnsureEmptyResultHandler(errorHandler), errorHandler, headerHandler);
        }
    }
}
